/**********************************************
  ECE 479 Winter 2010 
  Shrodinger's Cat 
  esra_module.h

  Function prototypes, gloabl variable and
  parameter declarations for the module

  Currently uses sox play for wav playback

**********************************************/

#ifndef ESRA_MODULE

#define ESRA_MODULE	1
#define PLAYERPATH "/usr/bin/play" //sox player path

#define NUMCOL           9	// Number of columns in the .csv file
//#define NUMCOL           7	// Number of columns in the .csv file
				// which is number of servos to be controlled
				// column number vs servo
				// 0 - Eyebrow
				// 1 - Upper lip
				// 2 - Lower Lip
				// 3 - Left Upper Arm
				// 4 - Right Upper Arm
				// 5 - Left Lower Arm
				// 6 - Right Lower Arm
				// 7 - Waist
				// 8 - Torso
				
#define PORT		"/dev/ttyS0" // Use a serial port
//#define PORT		"/dev/ttyUSB0" // Use a USB to Serial Adaptor 
#define BAUD		B9600	// Baud rate of 9600bps
#define SYNCSSC		255	// synchronization value with Mini SSC
#define INITPOS		127	// inital position

//#define DEBUG		1	// Enable Debug paramers
#define NANOTIME	1	// Enable nanotime for 0.033 sec delay for 30 fps

#define FRAMEDELAY 31000000	// Time delay between two frames

extern int (*valarray)[NUMCOL];	// 2-D array (numframe x NUMCOL)
				// stores the position values for each servo

extern int numframe;			// stores the number of frames to be read

int esra(char *argv[]); 	// The driver function to be called from 
				// the main program

int open_port(void);		// Open serial port defined above

int read_csv_file(const char *argv); // read servo position values
				// from .csv file

int set_pos_initial(int fd);	// set all servos to the initial position 127
int set_pos(int fd);		// drive servos

#endif //ESRA
